package com.cjkj.system.api.factory;

import com.cjkj.common.core.domain.R;
import com.cjkj.system.api.RemoteHospitalEquipmentService;
import com.cjkj.system.api.domain.APIEquipmentUsageRecords;
import com.cjkj.system.api.domain.APIHospitalEquipment;
import com.cjkj.system.api.domain.dto.APIEquipmentStatusDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 设备降级处理
 */
@Component
public class RemoteHospitalEquipmentFallbackFactory implements FallbackFactory<RemoteHospitalEquipmentService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteLogFallbackFactory.class);
    @Override
    public RemoteHospitalEquipmentService create(Throwable cause) {
        log.error("系统服务调用失败:{}", cause.getMessage());
        return new RemoteHospitalEquipmentService() {
            @Override
            public R<Integer> updateEquipmentStatus(APIEquipmentStatusDto dto, String source) {
                return R.fail("更新设备状态失败");
            }
            @Override
            public R<APIEquipmentUsageRecords> getRecordsByEquipment(String equipmentNo, String source) {
                return R.fail("获取设备使用记录失败");
            }

            @Override
            public R<Integer> updateEquipmentUsageRecordStatus(APIEquipmentUsageRecords dto, String source) {
                return R.fail("更新设备使用状态失败");
            }

            @Override
            public R<APIHospitalEquipment> getHospitalEquipmentInfo(String equipmentId, String source) {
                return R.fail("获取设备信息失败");
            }
        };
    }
}